package cc.ycws.api.controller;


import cc.ycws.api.utils.Http;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.stereotype.Controller;

@Controller
@RequestMapping("/ssm/yunba")
public class YunbaApi {
    /**
     * 云巴推送
     */
    @RequestMapping(value = "/push", produces = "text/html;charset=UTF-8")
    @ResponseBody
    public String push() throws Exception {
        String url = "http://rest.yunba.io:8080";    //url地址
        String appkey = "58d9c776691ac9095323544a"; //appkey
        String seckey = "sec-68vmBiSgmaLZ2S9VRe1BkhbvEjfxQ4oesv29ZczUJl5FkKz2"; //Secret Key
        //以JSON格式推送

        String json = "{'method':'publish', 'appkey':'" + appkey + "', 'seckey':'" + seckey + "', 'topic':'topic1'}";
        JSONObject jo = JSONObject.parseObject(json);
        //要推送的消息
        jo.put("msg", "abc");
        return Http.doPostByJson(url, json);
    }
}
